cmake_minimum_required(VERSION 3.20)
project(ts-comms LANGUAGES CXX)

# 必须在 project() 之后设置
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable compile commands export" FORCE)

# 自动检测构建类型
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
endif()

# 设置 Conan 生成文件路径
set(CONAN_GENERATORS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/conan/${CMAKE_BUILD_TYPE}")

# 包含 Conan 工具链文件
if(EXISTS "${CONAN_GENERATORS_DIR}/conan_toolchain.cmake")
    include("${CONAN_GENERATORS_DIR}/conan_toolchain.cmake")
    message(STATUS "Using Conan toolchain: ${CONAN_GENERATORS_DIR}/conan_toolchain.cmake")
else()
    message(WARNING "Conan toolchain file not found at ${CONAN_GENERATORS_DIR}/conan_toolchain.cmake")
endif()

# 添加 Conan 生成目录到搜索路径
list(APPEND CMAKE_PREFIX_PATH "${CONAN_GENERATORS_DIR}")
set(CMAKE_MODULE_PATH "${CONAN_GENERATORS_DIR}" ${CMAKE_MODULE_PATH})


add_executable(ts-comms src/main.cpp)
target_compile_features(ts-comms PRIVATE cxx_std_17)

install(TARGETS $ts-comms RUNTIME DESTINATION bin)
